<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>自然人基础变更申请页面</title>
	<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<div id="pageInTab" class="pageInTab">
				<div tabid="tabA" title="基本信息" lselected="true">
					<form id="formSet1">
						<div class="fieldset1 tabel_col clearFix">
							<div class="caption">
								<span class="title">基本信息</span>
                            </div>
                            <div class="fieldBox col_33 col_photo">
                                <div class="label">照片</div>
                                <div class="field">
                                    <img src="${mySelfImgUrlAll}" name="mySelfImgUrlAll" id="mySelfImgUrlAll"/>
                                </div>
                            </div>
                            <div class="fieldBox col_33">
                                <div class="label">客户类型</div>
                                <div class="field">
                                	<span class="requiredSymbol">自然人</span>
                                </div>
                            </div>
                            <div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">姓名</div>
			                    <div class="field">
			                        <input name="cstNm" id="cstNm" value="${cstNm }" type="text" class="ui-textbox" validate="{required:true,nmcharacter:true,maxlength:20}">
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
                            <div class="fieldBox col_33">
			                    <div class="label">性别</div>
			                    <div class="field">
			                        <c:forEach items="${searchSelectGenderCdList }" var="kv" begin="0" step="1" varStatus="status">
			                            <c:if test="${status.index == 0}">
			                                <input type="radio" value="${kv.key }" name="genderCd" checked />${kv.value }	
			                            </c:if>
										<c:if test="${status.index != 0}">
			                                <input type="radio" value="${kv.key }" name="genderCd" />${kv.value }	
			                            </c:if>
									</c:forEach>
			                    </div>
			                </div>
			                <div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">客户关系</div>
			                    <div class="field test_combo">
			                        <input name="cstRlTyp" id="cstRlTyp" type="text" ltype="combobox" placeholder="请选择"  validate="{required:true}"></input>
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
                            <div class="fieldBox col_33">
			                    <div class="label">证件类型</div>
			                    <div class="field">
			                        <select name="certTypCd" id="certTypCd" data-value="${npCertTypCd }" validate="{required:true, select: true}">
			                          <c:forEach items="${searchSelectNPCertTypCdList }" var="kv" begin="0" step="1" varStatus="status">
											<c:if test="${status.index == 0}">
											     <option value="${kv.key }" checked >${kv.value }</option>
											</c:if>
											<c:if test="${status.index != 0}">
											     <option value="${kv.key }">${kv.value }</option>
											</c:if>
									  </c:forEach>
			                        </select>
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
                            <div class="fieldBox col_33 col_fix_photo">
                                <div class="label">证件号</div>
                                <div class="field">
                                    <input name="certNo" id="certNo" type="text" class="ui-textbox" value="${certNo }" onchange="setNpPassNo();npVerifyIDEvent()" validate="{required:true}">
                                    <span class="requiredSymbol">*</span>
                                    <span id="sNpVerifyID" class="addNpVerifyID" onclick="npVerifyIDEvent()" style="display:none">
			                        	<a href="javascript:;" id="addNpVerifyID" pass='n' class="liger_tip" title="未验证"><i class="sqIco sqIco_8"></i></a>
			                    	</span>
                                </div>
                            </div>
                            <div class="fieldBox col_33">
			                    <div class="label">证件有效起始日期</div>
			                    <div class="field">
			                        <input name="certValidSDt" id="certValidSDt" type="text" class="ui-textbox" value="" disabled="disabled">
			                    </div>
			                </div>
			                <div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">证件有效终止日期</div>
			                    <div class="field">
			                        <input name="certValidEDt" id="certValidEDt" type="text" class="ui-textbox" value="" disabled="disabled">
			                    </div>
			                </div>
                            <div class="fieldBox col_33">
			                    <div class="label">手机号</div>
			                    <div class="field">
			                        <input name="mp1" id="mp1" type="text" class="ui-textbox" value="" validate="{required:true,mobile: true}" disabled="disabled">
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
			                <%--<div class="fieldBox col_33 col_fix_photo">--%>
			                    <%--<div class="label">手机号2</div>--%>
			                    <%--<div class="field">--%>
			                        <%--<input name="mp2" id="mp2" type="text" class="ui-textbox" value="" validate="{mobile: true}" disabled="disabled">--%>
			                    <%--</div>--%>
			                <%--</div>--%>
			                <div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">出生日期</div>
			                    <div class="field">
			                        <input name="birthday" id="birthday" type="text" class="ui-datepicker" value="" validate="{required:true}">
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
			                <div class="fieldBox col_33 ">
			                    <div class="label">年龄</div>
			                    <div class="field">
			                        <input name="age" id="age" disabled="disabled"  type="text" ligerui="{type:'int'}" class="ui-textbox" value="">
			                    </div>
			                </div>
							<div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">婚姻情况</div>
			                    <div class="field">
			                        <select name="marStsCd" id="marStsCd" data-value="" validate="{required:true, select: true}">
			                            <c:forEach items="${searchSelectMarStsCdList }" var="kv">
											<option value="${kv.key }">${kv.value }</option>
										</c:forEach>
			                        </select>
			                        <span class="requiredSymbol">*</span>
			                    </div>
							</div>
							
							<div id="cstGuarDynamicBizdiv">
			                	<%-- dynamic field --%>
			                </div>
			                <div id="cstGuar1DynamicBizdiv">
			                	<%-- dynamic field --%>
			                </div>
			                
			                <div class="fieldBox col_33">
			                    <div class="label">还款方式</div>
			                    <div class="field">
			                        <select name="payTypCd" id="payTypCd" data-value="" validate="{required:false, select: false}">
			                            <option value="">请选择</option>
			                            <c:forEach items="${payTyplist }" var="kv">
											<option value="${kv.key }">${kv.value }</option>
										</c:forEach>
			                        </select>
			                    </div>
			                </div>
			             	<div class="fieldBox col_33">
			                    <div class="label">立项控制</div>
			                    <div class="field">
			                        <select name="prjCtrlCd" id="prjCtrlCd" data-value="" validate="{required:false	, select: false}">
			                            <option value="">请选择</option>
			                            <c:forEach items="${prjCtrlCdList }" var="kv">
											<option value="${kv.key }">${kv.value }</option>
										</c:forEach>
			                        </select>
			                    </div>
			                </div>
			                
			                <!-- 业务形式 -->
							<ui:normalSelect pgCd="custCorpPage" cmpCd="custPageMainForm" cmpDtlCd="cstLvlCd" orgCds="${orgCds }"></ui:normalSelect>
                            
                            <div class="fieldBox col_100">
			                    <div class="label">户口所在地</div>
			                    <div class="field">
			                        <input name="idAddr" id="idAddr" type="text" class="ui-textbox" value="" validate="{required:true}" disabled="disabled">
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
			                <div class="fieldBox col_100">
			                    <div class="label">通讯地址</div>
			                    <div class="field">
			                        <input name="postAddr" id="postAddr" type="text" class="ui-textbox" value="" validate="{required:true}" disabled="disabled">
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
			                <div class="fieldBox col_100">
			                    <div class="label">备注</div>
			                    <div class="field" style="width: 100%;">
			                        <textarea name="cstRem"  id="cstRem" rows="4" class="l-textarea" style="width:99%" disabled="disabled"></textarea>
			                    </div>
			                </div>
                        </div>	
						<!-- 配偶信息 -->                        
                        <div id="PO_formSet" class="fieldset1 tabel_col tabel_col_s clearFix">
                            <div class="caption">
                                <span class="title">配偶信息</span>
                            </div>
                            <div class="fieldBox col_33 col_photo">
                                <div class="label">照片</div>
                                <div class="field">
                                    <img src="${myPeiOuImgUrlAll }" name="myPeiOuImgUrlAll" id="myPeiOuImgUrlAll"/>
                                </div>
                            </div>
							<div class="fieldBox col_33">
			                    <div class="label">姓名</div>
			                    <div class="field">
			                        <input name="rl_rlNm" id="rl_rlNm" type="text" class="ui-textbox" value="" >
			                        <span id="rlRlNmRequiredSymbol" class="requiredSymbol">*</span>
			                    </div>
			                </div>
			                <div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">性别</div>
			                    <div class="field">
			                        <c:forEach items="${searchSelectGenderCdList }" var="kv" begin="0" step="1" varStatus="status">
			                            <c:if test="${status.index == 0}">
			                                <input type="radio" value="${kv.key }" name="rl_genderCd" checked />${kv.value }	
			                            </c:if>
										<c:if test="${status.index != 0}">
			                                <input type="radio" value="${kv.key }" name="rl_genderCd" />${kv.value }	
			                            </c:if>
									</c:forEach>
			                    </div>
							</div>
			                <div class="fieldBox col_33">
			                    <div class="label">证件类型</div>
			                    <div class="field">
			                        <select name="rl_certTypCd" id="rl_certTypCd" data-value="" >
			                          <c:forEach items="${searchSelectNPCertTypCdList }" var="kv" begin="0" step="1" varStatus="status">
											<c:if test="${status.index == 0}">
											     <option value="${kv.key }" checked >${kv.value }</option>
											</c:if>
											<c:if test="${status.index != 0}">
											     <option value="${kv.key }">${kv.value }</option>
											</c:if>
									  </c:forEach>
			                        </select>
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
			                <div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">身份证号</div>
			                    <div class="field">
			                        <input name="rl_certNo" id="rl_certNo" type="text" class="ui-textbox" value="" validate="{required:false}" onchange="setPoPassNo();poVerifyId();">
			                        <span id="rlCertNoRequiredSymbol" class="requiredSymbol">*</span>
			                        <span id="peiouVerifyID" class="poVerifyID" onclick="poVerifyId();" style="display:none">
                                        <a href="javascript:;" id="poVerifyID" pass='n' class="liger_tip" title="未验证"><i class="sqIco sqIco_8"></i></a>
                                    </span>
			                    </div>
			                </div>
			                <div class="fieldBox col_33">
			                    <div class="label">出生日期</div>
			                    <div class="field">
			                        <input name="rl_birthday" id="rl_birthday" type="text" class="ui-datepicker" value="" validate="{required:false}">
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
                            <div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">手机号码</div>
			                    <div class="field">
			                        <input name="rl_mp" id="rl_mp" type="text" class="ui-textbox" value="" validate="{mobile: false}">
			                    	<span id="rlMpRequiredSymbol" class="requiredSymbol">*</span>
			                    </div>
			                </div>
			                <div class="fieldBox col_33">
			                    <div class="label">工作单位</div>
			                    <div class="field">
			                        <input name="rl_workPlc" id="rl_workPlc" type="text" class="ui-textbox" value="" validate="{maxlength:50}" disabled="disabled">
			                    </div>
			                </div>
							<div class="fieldBox col_33 col_fix_photo">
			                    <div class="label">单位电话</div>
			                    <div class="field">
			                        <input name="rl_tel" id="rl_tel" type="text" class="ui-textbox" value="" validate="{phone: false}" disabled="disabled">
			                    </div>
			                </div>
			                <div class="fieldBox col_100 col_fix_photo">
			                    <div class="label">户口所在地</div>
			                    <div class="field">
			                        <input name="rl_idAddr" id="rl_idAddr" type="text" class="ui-textbox" value="" disabled="disabled">
			                    	<span id="rlIdAddrRequiredSymbol" class="requiredSymbol">*</span>
			                    </div>
			                </div>
                            <div class="fieldBox col_100 col_fix_photo">
			                    <div class="label">单位地址</div>
			                    <div class="field">
			                        <input name="rl_workAddr" id="rl_workAddr" type="text" class="ui-textbox" value="" validate="{maxlength:150}" disabled="disabled">
			                    </div>
			                </div>
			                <div class="fieldBox col_100">
			                    <div class="label">备注</div>
			                    <div class="field">
			                    	<textarea name="rl_rlRem" id="rl_rlRem" rows="4" class="l-textarea" style="width:99%" validate="{maxlength:150}" disabled="disabled"></textarea>
			                    </div>
			                </div>
                        </div>
                        <div class="fieldset1 tabel_col tabel_col_s clearFix">
                            <div class="caption">
                                <span class="title">辅助信息</span>
                            </div>
			                <div class="fieldBox col_33">
			                    <div class="label">工作单位</div>
			                    <div class="field">
			                        <input name="workPlc" id="workPlc" type="text" class="ui-textbox" value="" disabled="disabled">
			                    	<span id="workPlcRequiredSymbol" class="requiredSymbol">*</span>
			                    </div>
			                </div>
							<div class="fieldBox col_33">
			                    <div class="label">从业年限</div>
			                    <div class="field">
			                        <input name="workYrs" id="workYrs" type="text" class="ui-textbox" value="" disabled="disabled">
			                    </div>
			                </div>
			                <div class="fieldBox col_100">
			                    <div class="label">单位地址</div>
			                    <div class="field">
			                        <input name="workAddr" id="workAddr" type="text" class="ui-textbox" value="" disabled="disabled">
			                    </div>
			                </div>
							<!-- hide data -->
			                <div class="fieldBox col_100" style="display:none;">
			                    <div class="field">
			                         <input name="cId" id="cId" onclick="" type="text" class="ui-textbox" value="${id}"/>
			                         <input name="mySelfImgUrl" id="mySelfImgUrl" type="text" class="ui-textbox" value="${mySelfImgUrl}"/>
			                         <input name="myPeiOuImgUrl" id="myPeiOuImgUrl" type="text" class="ui-textbox"/>
			                    </div>
			                </div>
			                <div class="fieldBox col_100" id="fileModify">
								<div class="label">资料</div>
								<div class="field">
				                	<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true" >
				                   		<jsp:param name="pkId" value="${id }"/>
				                   		<jsp:param name="tabNm" value=""/>
				                 	</jsp:include>
				            	</div>
							</div>
							<div class="fieldBox col_100" style="display:none;">
								<div class="label">资料上传</div>
								<div class="field">
				                   	<jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true" >
				                   		<jsp:param name="filePath" value="customer"/>
				                   	</jsp:include>
								</div>
							</div>
						</div>
						<c:if test="${isModify == '1' }">
	                        <div class="btnsBox">
	                            <span id="saveCustNpInfoBtn1" class="sq-button sq-button-round">保存</span>
	                        </div>
                        </c:if>
                    </form>
                    <div class="sqPanel">
                        <div class="sqPanel_head inL">
                            <div class="btnsBox inLC" style="display:none;">
                                <span id="cst_rl_add_btn" class="sq-button sq-button-round">添加</span>
                                <span id="cst_rl_modify_btn" class="sq-button sq-button-round">修改</span>
                            </div>
                            <span>社会关系/家庭成员</span>
                        </div>
                        <div class="sqPanel_body">
                            <div id="ligergrid_A1" class="sq-grid"></div>
                        </div>
                    </div>
                </div>
                <div tabid="tabB" title="银行账号" id="tabBId" style="dis">
                    <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
                </div>
                <div tabid="tabH" title="项目列表" id="tabHId" style="dis">
                    <iframe frameborder="0" name="tabH" id="tabH" src=""></iframe>
                </div>
                <div tabid="tabD" title="征信信息" id="tabDId" style="dis">
                   <iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
                </div>
                <div tabid="tabF" title="中间人" id="tabFId">
                    <iframe frameborder="0" name="tabF" id="tabF" src=""></iframe>
                </div>
				<div tabid="tabG" title="沟通记录" id="tabGId">
                    <iframe frameborder="0" name="tabG" id="tabG" src=""></iframe>
                </div>
				<div tabid="tabK" title="风险标记" id="tabKId">
					<iframe frameborder="0" name="tabK" id="tabK" src=""></iframe>
				</div>
	            <div tabid="tabP" title="担保项目列表" id="tabPId" style="dis">
	                <iframe frameborder="0" name="tabP" id="tabP" src=""></iframe>
	            </div>
				<div tabid="tabR" title="变更记录">
					<iframe frameborder="0" name="tabR" id="tabR" src=""></iframe>
				</div>
            </div>
        </div>
    </div>
    <script>
    var pageInApp={
    		flag:true
    }; // to 下一级子窗口 接口
    var pageInTab=null;
    var loadedTabs=[];
    var npSocialRlGrid; //自然人关系Grid
    var _mySelfIDImgUrl=""; //客户本人身份证图片地址,待验证过后返回
    
    var isFlow = '${isFlow}'; //流程标识 1：是，0或者空：否
    var modId = '${modId}'; //变更主表ID（流程业务主键）
	var isModify = '${isModify}'; //是否可修改基本信息，1：是，0：否
	var _audStsCd = '${_audStsCd}'; //客户状态（13：已立项  14：有担保项目）
    var currentBuOrgCd = '${currentBuOrgCd}'; //发起人所属事业部代码
    
    $(function() {
        initData();//初始化数据
        initEvent();//初始化事件
        //根据修改标识设置表单域可编辑否
        if('${isModify}' == '1'){//可修改
        	changeModStatus(false);
        }else{//不可修改
        	changeModStatus(true);
        }
    });
    
	//初始化数据
    function initData(){
        initCstRlCombox();//注意*****这个初始化只能排在第一位
        //initIndCdTree();
    	initTab();
    	initForm();//初始化表单
        initCstRlGrid();//初始化社会关系
        initBtn();
    	initCstInfo();//初始化客户数据
    	initFormData();//初始化默认的数据
    }
    
  	//初始化事件
    function initEvent(){
    	checkIsOrNot();
    	marStsCdEvent();
    	saveCustNpInfoBtnEvent();
    	cstRlAddBtnEvent();
    	cstRlModifyBtnEvent();
    	birthdayChangeEvnet();
    	//新增的时候在事件执行完成后在加载
    	var _id = $("#cId").val();
    	if(!_id){
    		getIdCartBirthday();
    	}
	}
  	
    function checkIsOrNot(){
    	//禁用不可修改项
    	liger.get("cstRlTyp").setDisabled(true);//客户关系
    	liger.get("birthday").setDisabled(true);//出生日期
    	liger.get("marStsCd").setDisabled(true);//婚姻情况
    	liger.get("payTypCd").setDisabled(true);//还款方式
    	liger.get("prjCtrlCd").setDisabled(true);//立项控制
    	liger.get("rl_birthday").setDisabled(true);//配偶-出生日期
    	liger.get("rl_certTypCd").setDisabled(true);//配偶-证件类型
    	//禁用性别单选组
		$("#formSet1").find('input[name=genderCd]').each(function (){
			$(this).attr("disabled",true);
        });
		$("#formSet1").find('input[name=rl_genderCd]').each(function (){
			$(this).attr("disabled",true);
        });
    	//禁用证件类型
    	liger.get("certTypCd").setDisabled(true);
		$("#rl_certTypCd").change(function(event) {
			if($(this).val()==0){
				$("#peiouVerifyID").show();
			}else{
				$("#peiouVerifyID").hide();
			}
		});
	}
  	
	//初始化所属行业Tree, 这个组件为动态组件, 要做存在判断
    var indCdTree;
    function initIndCdTree(){
    	if($("#indCd").length <= 0){
    		return;
    	};
    	//加载数据
    	indCdTree1 = $("#indCd").ligerComboBox({
             selectBoxWidth: 240,
             selectBoxHeight: 150,
             treeLeafOnly: false, //限制只能选叶节点，父节点不能点击
             tree: {
            	 url: '<%=path%>/customer/cstbscinfo/initIndCdTree.do',
            	 ajaxType: 'get',
                 checkbox: false,
                 parentIcon: "none",
                 childIcon: "none",
                 onSuccess:function(){
                	 if(indCdVal){//这里和赋值方法里面都有一个赋值,因为在赋值操作和这个下拉框赋值操作是异步的,谁在前谁在后不好说,所以在两个地方根据indCdVal是否存在来赋值数据
                		 var treeselect=liger.get("indCd");
                	 	 if(treeselect){
	                       	 treeselect.setValue(indCdVal);
                	 	 }
                	 }
                	 //如果客户为新增则赋值默认值
                	var cId = $("#cId").val();
                    if(!cId){
                    	var treeselect=liger.get("indCd");
                    	if(treeselect){
                           treeselect.setValue(CustomerConstant.CST_IND_CD_JTYS);
                     	}
                    }
                 }
             },onChangeValue: function (value) {
                 /* if(value == LogUtils.LOG_CUST_SELECT_OTHER_VALUE){
                	 $("#othIndCdDiv").removeClass('Hide');
                 }else{
                	 $("#othIndCdDiv").addClass('Hide');
                 } */
             }
         });
    }
  	
    var isHaveCstRlTypeDBR = false;
  	//初始化客户关系类型下框框
    function initCstRlCombox(){
  		var cstRlTypChange = false;//只为了在加载初始化的时候不加载onChangeValue 事件,带前端解决后即可删除
    	var _cstRlTypJson = ${cstRlTypCdList};
    	var cstRlTypLCB = $("#cstRlTyp").ligerComboBox({ 
    		isShowCheckBox: true, 
    		isMultiSelect: true,
            data: _cstRlTypJson,
            valueField: 'key',
            textField:'value',
            onChangeValue :function(value){
            	if(!cstRlTypChange)return;
            	
            	var _cstRlTypObj = liger.get("cstRlTyp");
            	var _cstRlTypValues = _cstRlTypObj.getValue();
            	//alert(_cstRlTypValues);
            	var formSet1 = liger.get("formSet1");
            	//如果是担保人则加载
            	if(_cstRlTypValues.indexOf(CustomerConstant.CST_RL_TYPE_DBR_CD) != -1 && isHaveCstRlTypeDBR == false){
            		reloadCstRlTypDBR(CustomerConstant.CST_RL_TYPE_DBR_CD);
            		isHaveCstRlTypeDBR = true;
            	}else if(_cstRlTypValues.indexOf(CustomerConstant.CST_RL_TYPE_DBR_CD) == -1 && isHaveCstRlTypeDBR == true){
            		reloadCstRlTypDBR(-1);
            		isHaveCstRlTypeDBR = false;
            	}
            	
            	var marriageState_val = $("#marStsCd").val();//婚姻状况
            	
            	if(formSet1){
            		if(_cstRlTypValues == CustomerConstant.CST_RL_TYPE_DBR_CD){//只是担保人的时候
                		//担保人的时候部分字段非必填项设置：居住地邮编、单位地址邮编、居住状况、本单位工作起始年份、客户分级、最高学历、电子邮箱
                		formSet1.setFieldValidate("homeZip", {required: false});
                		$("#homeZipRequiredSymbol").hide();
                		formSet1.setFieldValidate("officeZip", {required: false});
                		$("#officeZipRequiredSymbol").hide();
                		formSet1.setFieldValidate("livCndCd", {required: false});
                		$("#livCndCdRequiredSymbol").hide();
                		formSet1.setFieldValidate("workStYr", {required: false});
                		$("#workStYrRequiredSymbol").hide();
                		formSet1.setFieldValidate("cstLvlCd", {required: false});
                		$("#cstLvlCdRequiredSymbol").hide();
                		formSet1.setFieldValidate("highDgCd", {required: false});
                		$("#highDgCdRequiredSymbol").hide();
                		formSet1.setFieldValidate("email", {required: false});
                		$("#emailRequiredSymbol").hide();
                		
                		//选择已婚状态下-担保人可以不添加配偶信息 2017-05-15
                		if (marriageState_val==CustomerConstant.CST_MAR_STS_CD_2 
			        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_first
			        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_agian
			        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_back
			            	) {
	                			formSet1.setFieldValidate("rl_rlNm", {required: false});
	                     		$("#rlRlNmRequiredSymbol").hide();
	                     		formSet1.setFieldValidate("rl_certNo", {required: false});
	                     		$("#rlCertNoRequiredSymbol").hide();
	                        	formSet1.setFieldValidate("rl_mp", {required: false});
	                     		$("#rlMpRequiredSymbol").hide();
	                        	formSet1.setFieldValidate("rl_idAddr", {required: false});
	                     		$("#rlIdAddrRequiredSymbol").hide();
			            }
                	}else{
                		//有客户存在的情况下必须要添加配偶信息 2017-05-15
                		if (marriageState_val==CustomerConstant.CST_MAR_STS_CD_2 
			        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_first
			        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_agian
			        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_back
			            	) {
	                			formSet1.setFieldValidate("rl_rlNm", {required: true});
	                    		$("#rlRlNmRequiredSymbol").show();
	                    		formSet1.setFieldValidate("rl_certNo", {required: true});
	                    		$("#rlCertNoRequiredSymbol").show();
	                       		formSet1.setFieldValidate("rl_mp", {required: true});
	                    		$("#rlMpRequiredSymbol").show();
	                       		formSet1.setFieldValidate("rl_idAddr", {required: true});
	                    		$("#rlIdAddrRequiredSymbol").show();
			            }
                	}
            	}
            }
        });
    	cstRlTypChange = true;
    	//这里要判断是新增的时候才赋值默认
    	var _cId = $("#cId").val();
        if(!_cId){
        	var currentCstRlTypeForAdd = ${currentCstRlTypeForAdd};
    		$("#cstRlTyp").ligerGetComboBoxManager().setValue(currentCstRlTypeForAdd);//注意变成常量
        }
     }
  	
 	//刷新担保人组件
  	function reloadCstRlTypDBR(_bizCd){
  		var _url = '<%=path%>/customer/cstbscinfo/toCstGuarDynamicPage.do';
		//如果有参数则在第二个参数中传入
		$("#cstGuarDynamicBizdiv").load(_url,{bizCd:_bizCd},function(responseText,textStatus){
			    $("#formSet1").check_ligerFormEditor();//重新刷新页面动态字段
				var form = new liger.get("formSet1");
    			form.setData({
    				guarTypCd:tempGuarTypCd,
    				guarAmt:tempGuarAmt
    			});
				if (liger.get("guarTypCd")) {//担保方式-禁用
		            liger.get("guarTypCd").setDisabled(true);
		        }
		        if (liger.get("guarAmt")) {//最高保证金额(元)-禁用
		            liger.get("guarAmt").setDisabled(true);
		        }
		});
		
		//重新赋值使用
		_url = '<%=path%>/customer/cstbscinfo/toCstDynamicPageForNp.do';
		//如果有参数则在第二个参数中传入
		$("#cstGuar1DynamicBizdiv").load(_url,{bizCd:_bizCd},function(responseText,textStatus){
			    $("#formSet1").check_ligerFormEditor();//重新刷新页面动态字段
				var form = new liger.get("formSet1");
    			form.setData({
    				schr7:tempSchr7,
    				usedNm:tempUsedNm,
    				drvLicTyp:tempDrvLicTyp,
    				nation:tempNation
    			});
    			if (liger.get("schr7")) {//工作单位性质-禁用
		            liger.get("schr7").setDisabled(true);
		        }
		        if (liger.get("usedNm")) {//曾用名-禁用
		            liger.get("usedNm").setDisabled(true);
		        }
		        if (liger.get("drvLicTyp")) {//驾照类型-禁用
		            liger.get("drvLicTyp").setDisabled(true);
		        }
		        if (liger.get("nation")) {//民族-禁用
		            liger.get("nation").setDisabled(true);
		        }
		});
  	}
 	
  	//初始化Tab
    function initTab(){
    	 pageInTab = $("#pageInTab").ligerTab({
             height: 'auto',
             contextmenu: false,
             minIframeHeight: GET_minIframeHeight(),
             onReload: function () {
             },
             onBeforeSelectTabItem: function (tabid) {
             	var _cId = $("#cId").val();
             	if(tabid!="tabA"&& tabid != "tabK"){
 	            	if(pageInApp.flag){
 	            		UIUtils.alertWarning(LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO);
 	                	return false;
 	                }
             	}
             },
             onAfterSelectTabItem: function(tabid) {
                 if (loadedTabs.indexOf(tabid)<0) {
                 	//获取客户ID供其它页面使用
                 	var _cId = $("#cId").val();
                 	var _cstNm = $("#cstNm").val();
                 	if(tabid!="tabA"){
 	                	if(!_cId){
 	                		 UIUtils.alertWarning(LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO);
 	                         return false; //验证不通过，不执行以下代码
 	                	}
                 	}
					loadedTabs.push(tabid);
					switch (tabid) {
	                     case "tabB":
	                         pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbank/toCustCstBacInfoNpBankDetailListPage.do?cstId=" + _cId);
	                         break;
	                     case "tabH":
	                         var parms = "?cstId=" + _cId + "&cstNm=" + _cstNm;
	                         pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toCstProjectDetailPage.do" + parms);
	                         break;
	                     case "tabC":
	                         pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toCustCstBacInfoEpAssetPage.do?cstId=" + _cId);
	                         break;
	                     case "tabD":
	                         pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toCstCreditPage.do?cstId=" + _cId);
	                         break;
	                     case "tabF":
	                         pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstmidmaninfo/toDetailListPage.do?cstId=" + _cId);
	                         break;
	                     case "tabG":
	                         pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstcommrec/toDetailListPage.do?cstId=" + _cId);
	                         break;
	                     case "tabK":
	                         var parms = "?cstId=" + _cId + "&cstNm=" + _cstNm;
	                         pageInTab.setTabItemSrc(tabid, "<%=path%>/risk/rskCstSignLog/toListPage.do" + parms);
	                         break;
						 case "tabP":
                             var cstRlTyp = liger.get("cstRlTyp").getValue(); //客户关系：1 客户 2担保人
                             if (cstRlTyp.search("2") != -1) { //担保人
                                var parms = "?cstId=" + _cId + "&cstNm=" + _cstNm;
                                pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toPrjCstBscDetailPage.do" + parms);
                             } else {
                                $.ligerDialog.SQalert({content: "该客户不是担保人，无担保项目！", SQ_type: "warning"});
                             }
                             break;
                         case "tabR"://变更记录
                        	 pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toModRecListPage.do?modId=" + modId + '&cId=' + _cId);
                             break;
	     			}
                 };
                 SetIframe_height();
             }
         });

         $.extend(true, pageInApp, {
             pageInTab: pageInTab
         });
    }
  	
    //初始化社会关系
    function initCstRlGrid() {
    	var _cId = $("#cId").val();
    	$("#ligergrid_A1").ligerGrid({
        	usePager: false,
            url: '<%=path%>/customer/cstnpsocialrl/initList.do',
            delayLoad:true,
	    	method : 'get',
            columns: [{
                display: '关系',
                name: 'rlTypCdNm',
                isSort: false,
                width: 120,render: function (rowdata, rowindex, value, column) { 
                	if(StringUtils.isEmpty(value)){
                		value = "";
                	}
            		var h = '';
        		    h='<a  href="javascript:cstRlDetailBtnEvent(';
                    h+="'"+rowdata.id+"'";
                    h+=')">'+value+'</a>'
                    return h;
        		}
            }, {
                display: '姓名',
                name: 'rlNm',
                isSort: false,
                minWidth: 60,
                align:'center',render: function (rowdata, rowindex, value, column) { 
                	if(StringUtils.isEmpty(value)){
                		value = "";
                	}
            		var h = value;
            		if(StringUtils.isNotEmpty(rowdata.rlCstId)){
            			 h='<a  href="javascript:toCstDetailBtnEvent(';
                         h+="'"+rowdata.rlCstId+"'";
                         h+=')">'+value+'</a>'
            		}
                    return h;
        		}
            }, {
                display: '手机号',
                name: 'mp',
                isSort: false,
                width: 150,
            }, {
                display: '职位',
                name: 'pos',
                isSort: false,
                minWidth: 200
            }, {
                display: '证件类型',
                name: 'certTypCdNm',
                isSort: false,
                minWidth: 200
            }, {
                display: '证件号',
                name: 'certNo',
                isSort: false,
                minWidth: 140
            }, {
                display: '单位地址',
                name: 'workAddr',
                isSort: false,
                minWidth: 140
            }],
            pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        isScroll: false,
	        checkbox:true,
	        rownumbers:true,
            onAfterShowData: function() {
                if (parent.mainApp) parent.mainApp.parentTab.onResize();
            }
		});
		npSocialRlGrid = liger.get("ligergrid_A1");
    };
    
    //初始化表单
    function initForm(){
    	$("#formSet1").ligerForm({
            validate: true,
            onAfterSetFields: function () {
                $("#PO_formSet").addClass('Hide');
            }
        });
    	$("#formSet1").check_ligerFormEditor();//重新刷新页面动态字段
    };
    
    //婚姻情况下拉事件
    function marStsCdEvent(){
    	$("#marStsCd").change(function(event) {
            var marriageState_val=$(this).val();
            var formSet1=liger.get("formSet1");
            //alert(marriageState_val);
            if (marriageState_val==CustomerConstant.CST_MAR_STS_CD_2 
        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_first
        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_agian
        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_back
            	) {
                $("#PO_formSet").removeClass('Hide');
                $("#PO_formSet").ligerForm({validate: true})
                // 设置《必选》验证规则
                formSet1.setFieldValidate("rl_rlNm", {required: true, nmcharacter:true});
                formSet1.setFieldValidate("rl_certNo", {required: true});
                formSet1.setFieldValidate("rl_mp", {required: true, mobile: true});
                formSet1.setFieldValidate("rl_idAddr", {required: true});
                formSet1.setFieldValidate("rl_birthday", {required: true});
                SetIframe_height();
            }else{
                $("#PO_formSet").addClass('Hide');
                $("#PO_formSet").ligerForm({validate: false})
                // 取消《必选》验证规则
                formSet1.setFieldValidate("rl_rlNm", {required: false, nmcharacter:true});
                formSet1.setFieldValidate("rl_certNo", {required: false});
                formSet1.setFieldValidate("rl_mp", {required: false, mobile: false});
                formSet1.setFieldValidate("rl_idAddr", {required: false});
                formSet1.setFieldValidate("rl_birthday", {required: false});
            };
        });
    };
    
    //保存事件
    function saveCustNpInfoBtnEvent(){
    	$("#saveCustNpInfoBtn1").click(function(event) {
            var formSet1 = liger.get("formSet1");
            if (!formSet1.valid()) {
            	UIUtils.alertWarning(LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO);
                return false; //验证不通过，不执行以下代码
            }
            //判断页面是否有变更
            if(isChange == 0){
            	UIUtils.alertWarning("客户信息无变更，不允许发起流程！");
                return false; 
            }
            saveBscInfo();//保存
        });
    };
    
	//发起主要信息变更流程
    function startCstModFlow() {
        var modelTyp = 'C001';//流程业务分类
        if (StringUtils.isEmpty(modelTyp)) {
            return;
        }
        var flowDialog = $.ligerDialog.SQopen({
            url: '<%=path%>/flow/flow/toForStartListPage.do?modelTyp=' + modelTyp,
            width: 700,
            height: 400,
            title: '请选择要发起的流程',
            buttons: [{
                text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
                onclick: function (item, Dialog) {
                    if (Dialog.onOk) {
                        $.ligerDialog.SQconfirm('是否确定发起变更流程?', function (flag) {
                            if (flag == false) {
                                return;
                            } else {
                                Dialog.onOk();
                            }
                        })
                    }
                }
            }, {
                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                onclick: function (item, Dialog) {
                    if (Dialog.onCancel) Dialog.onCancel();
                }
            }
            ],
            onClose: function () {
                var json = flowDialog._DATA;
                if (!json) {
                    return;
                }
                //saveBscInfo(json);
            }
        });
    }
    
    //新增社会关系
    function cstRlAddBtnEvent(){
        $("#cst_rl_add_btn").click(function(event) {
        	//如果客户ID不存在是不能新增
        	var _cId = $("#cId").val();
        	if(!_cId){
        		UIUtils.alertWarning(LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO);
                return; //验证不通过，不执行以下代码
        	}
        	
            $.ligerDialog.SQopen({
                width: 800,
                height:420,
                title : '社会关系/家庭成员',
                url:'<%=path%>/customer/cstnpsocialrl/toAddPage.do?cstId='+_cId,
                // 自定义buttons的时候 不要设置 fixButtons: true
                buttons: [{
                        text: "保存",  type: 'ok', cls: 'l-dialog-btn-ok',
                        onclick: function (item, Dialog) {
                            //在子页面里绑定 frameElement.dialog.onOk = function () {}
                           if (Dialog.onOk) Dialog.onOk();
                        }
                    }, {
                        text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                        onclick: function (item, Dialog) {
                            //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                            if (Dialog.onCancel) Dialog.onCancel();
                       } 
                    }
                ]
            });
        });
    };
    
    //修改社会关系
    function cstRlModifyBtnEvent(){
    	$("#cst_rl_modify_btn").click(function(event) {
        	//如果客户ID不存在是不能修改
        	var _cId = $("#cId").val();
        	if(!_cId){
        		UIUtils.alertWarning(LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO);
                return; //验证不通过，不执行以下代码
        	}
        	
        	var selectedRows = npSocialRlGrid.getSelectedRows();
    		if(selectedRows.length != 1){
    			UIUtils.alertWarning(LogUtils.LOG_CMM_SELECT_ONLY_A_ROW);
    			return;
    		}

			if(selectedRows[0].rlTypCdNm == "本人"){
				UIUtils.alertWarning("本人数据不可操作");
				return;
			}
    		
    		var _id = selectedRows[0].id;
        	
            $.ligerDialog.SQopen({
                width: 800,
                height:420,
                title : '社会关系/家庭成员',
                url:'<%=path%>/customer/cstnpsocialrl/toAddPage.do?cstId='+_cId+'&rId='+_id,
                // 自定义buttons的时候 不要设置 fixButtons: true
                buttons: [{
                        text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
                        onclick: function (item, Dialog) {
                            //在子页面里绑定 frameElement.dialog.onOk = function () {}
                            if (Dialog.onOk) Dialog.onOk();
             	        }
                    }, {
                        text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
                        onclick: function (item, Dialog) {
              	           //在子页面里绑定 frameElement.dialog.onCancel = function () {}
              	           if (Dialog.onCancel) Dialog.onCancel();
              	        }
                    }
                ]
            });
        });
    }
    
    //社会关系详细
    function cstRlDetailBtnEvent(_id){
           $.ligerDialog.SQopen({
                width: 800,
                height:420,
                title : '社会关系/家庭成员',
                url:'<%=path%>/customer/cstnpsocialrl/toDetailPage.do?rId='+_id,
             	// 自定义buttons的时候 不要设置 fixButtons: true
                buttons: [{
                        text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no',
                        onclick: function (item, Dialog) {
              	           //在子页面里绑定 frameElement.dialog.onCancel = function () {}
              	           if (Dialog.onCancel) Dialog.onCancel();
              	        }
                    }
                ]
                		
           });
    }
    
    //到客户查看页面
    function toCstDetailBtnEvent(_cstId){
    	Add_navTab('tab_cst_detail'+_cstId,'客户详情','<%=path%>/customer/cstbscinfo/toCustDetailPage.do?id='+_cstId);
    }
    
    
    //如果是身份证就获取生日  15位或者 18位
    function getIdCartBirthday(){
    	var val = $("#certNo").val();
    	var npCertTypCd = "${npCertTypCd }";
    	if(!val||npCertTypCd!=0){
    		return;
    	}
    	
    	if(!RegexUtils.isIDCard(val)){
    		return;
    	}
    	
    	var year = "";
    	var month = "";
    	var day = "";
    	if(val.length == 15){//获取生日 15截取7-12, 年份+19**
    		year = "19" + val.substring(6,8);
    		month = val.substring(8,10);
    		day = val.substring(10,12);
    	}else if(val.length == 18){//获取生日 18截取7-14
    		year = val.substring(6,10);
    		month = val.substring(10,12);
    		day = val.substring(12,14);
    	}
    	$("#birthday").val(year + "-" + month + "-" + day);
    	$("#birthday").trigger("change");
    }
    
  	//生日变更事件
    function birthdayChangeEvnet(){
		$("#birthday").ligerDateEditor({
				format: "yyyy-MM-dd",
				labelAlign: 'center',
				//cancelable : false,
				onChangeDate:function(value){
					value = value.replace(/-/g,"/") + " 00:00:00";
					var newDateYear = new Date(value).getFullYear();
					var currentYear = new Date().getFullYear();
					var age = currentYear - newDateYear;
					if(age > 0){
						$("#age").val(age);
					}else{
						$("#age").val(0);
					}
				}
		});
    };
    
    //初始化客户信息
    var tempData;//主要用与动态表单在加载完成后需要赋值的情况,如修改页面加载数据
    var tempGuarTypCd;
    var tempGuarAmt;
    var tempSchr7;//工作单位性质
    var tempUsedNm;
	var tempDrvLicTyp;
	var tempNation;
    function initCstInfo(){
    	var _id = $("#cId").val();
    	if(!_id){
    		return;	
    	}
    	
    	var _url = '<%=path%>/customer/cstbscinfo/getById.do';
    	//判断是否有变更主表ID-是否流程中
    	if(modId){
            _url = '<%=path%>/customer/cstbscinfo/getCstInfoFlowById.do';
		}
    	AjaxUtils.ajaxGet(_url, {id:_id, modId:modId, currentBuOrgCd:currentBuOrgCd}, function(msg){
    		if(msg.success == 1){
				 setData(msg.data);//设置数据
				 tempData = msg.data;
				 pageInApp.flag=false;
				 reloadCstRlGrid(_id);
			 }else{
				 UIUtils.alertError(msg.info);
			 }
			 disableCustomerTYPE();
    	},true);
    }
    
    //禁用客户类型选项
    function disableCustomerTYPE(){
    	if($("[name=customerTYPE]")){//特殊情况使用
    		var obj = $("[name=customerTYPE]");
    		obj.setDisabled_ligerRadio(true);
    	};
    }
    
  	//初始化按钮
  	function initBtn(){
  		//如果是修改操作则隐藏解锁按钮
  		$("#openLockCustNpInfoBtn").hide();
  	}
	
    //设置页面数据
    var indCdVal;
    function setData(data){
    	var form = new liger.get("formSet1");
    	form.setData({
    		cstLvlCd:data.cstLvlCd,
    		cstStsCd:data.cstStsCd,
    		certTypCd:data.certTypCd,
    		cstCd:data.cstCd,
    		cstNm:data.cstNm,
    		cstRem:data.cstRem,
    		certNo:data.certNo,
    		othIndCd:data.othIndCd,
    		payTypCd:data.payTypCd
    	});
    	
    	//如果证件号码或者名称为空则要放开禁用功能
    	if(StringUtils.isEmpty(data.cstNm)){
    		liger.get("cstNm").setEnabled(true);
    	}
		if(StringUtils.isEmpty(data.certNo)){
			liger.get("certNo").setEnabled(true);
    	}
    	
    	//我自己的身份证照片
    	if(StringUtils.isNotEmpty(data.mySelfIDImgUrl)){
	    	$("#mySelfImgUrlAll").attr('src',data.mySelfIDImgUrl); 
    	}
    	
    	//我配偶的身份证照片
    	if(StringUtils.isNotEmpty(data.myPeiOuIDImgUrl)){
    		$("#myPeiOuImgUrlAll").attr('src',data.myPeiOuIDImgUrl);
    	}
    	
    	indCdVal = data.indCd;
		 if(indCdVal){
			 var treeselect=liger.get("indCd");
			 if(treeselect){
              	 treeselect.setValue(indCdVal);
   	 	 	 }
		 }
    	
    	if(data.cstNpBscInfoVO){
    		var _workStYr = data.cstNpBscInfoVO.workStYr;
    		tempUsedNm = data.cstNpBscInfoVO.usedNm;
    		tempDrvLicTyp = data.cstNpBscInfoVO.drvLicTyp;
    		tempNation = data.cstNpBscInfoVO.nation;
    		if(StringUtils.isNotEmpty(_workStYr)){
    			_workStYr = new Date(_workStYr);
    		}
    		form.setData({
        		mp1:data.cstNpBscInfoVO.mp1,
        		mp2:data.cstNpBscInfoVO.mp2,
        		eduLvlCd:data.cstNpBscInfoVO.eduLvlCd,
        		marStsCd:data.cstNpBscInfoVO.marStsCd,
        		zipNo:data.cstNpBscInfoVO.zipNo,
        		homeTel:data.cstNpBscInfoVO.homeTel,
        		age:data.cstNpBscInfoVO.age,
        		workTel:data.cstNpBscInfoVO.workTel,
        		workPlc:data.cstNpBscInfoVO.workPlc,
        		idAddr:data.cstNpBscInfoVO.idAddr,
        		homeAddr:data.cstNpBscInfoVO.homeAddr,
        		postAddr:data.cstNpBscInfoVO.postAddr,
        		workAddr:data.cstNpBscInfoVO.workAddr,
        		workYrs:data.cstNpBscInfoVO.workYrs,
        		ocpCd:data.cstNpBscInfoVO.ocpCd,
        		posCd:data.cstNpBscInfoVO.posCd,
        		titCd:data.cstNpBscInfoVO.titCd,
        		highDgCd:data.cstNpBscInfoVO.highDgCd,
        		livCndCd:data.cstNpBscInfoVO.livCndCd,
        		/* cstLvlCd:data.cstNpBscInfoVO.cstLvlCd, */
        		email:data.cstNpBscInfoVO.email,
        		yrInc:data.cstNpBscInfoVO.yrIncStr,
        		officeZip:data.cstNpBscInfoVO.officeZip,
        		workStYr:_workStYr,//特殊处理,必须是时间对象
        		homeZip:data.cstNpBscInfoVO.homeZip,
        		usedNm:data.cstNpBscInfoVO.usedNm,
        		drvLicTyp:data.cstNpBscInfoVO.drvLicTyp,
        		nation:data.cstNpBscInfoVO.nation,
        		certValidSDt:data.cstNpBscInfoVO.certValidSDt,
        		certValidEDt:data.cstNpBscInfoVO.certValidEDt,
        		homeTel:data.cstNpBscInfoVO.homeTel,
        		workTel:data.cstNpBscInfoVO.workTel
        	});
    		
    		$("input[name='genderCd'][value="+data.cstNpBscInfoVO.genderCd+"]").prev(".l-radio").click();
        	if(data.cstNpBscInfoVO.birthday){
        		var date = new Date(data.cstNpBscInfoVO.birthday);
        		var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        		//alert(data.cstNpBscInfoVO.birthday);
        		$("#birthday").val(dateStr);
        		dateStr = dateStr.replace(/-/g,"/") + " 00:00:00";
    			var newDateYear = new Date(dateStr).getFullYear();
    			var currentYear = new Date().getFullYear();
    			var age = currentYear - newDateYear;
    			if(age > 0){
    				$("#age").val(age);
    			}else{
    				$("#age").val(0);
    			}
        	}	
    		
        	//显示配偶信息
        	if(data.cstNpBscInfoVO.cstNpSocialRlVO){
            	form.setData({
            		rl_rlNm:data.cstNpBscInfoVO.cstNpSocialRlVO.rlNm,
            		rl_certTypCd:data.cstNpBscInfoVO.cstNpSocialRlVO.certTypCd,
            		rl_certNo:data.cstNpBscInfoVO.cstNpSocialRlVO.certNo,
            		rl_mp:data.cstNpBscInfoVO.cstNpSocialRlVO.mp,
            		rl_workPlc:data.cstNpBscInfoVO.cstNpSocialRlVO.workPlc,
            		rl_tel:data.cstNpBscInfoVO.cstNpSocialRlVO.tel,
            		rl_idAddr:data.cstNpBscInfoVO.cstNpSocialRlVO.idAddr,
            		rl_workAddr:data.cstNpBscInfoVO.cstNpSocialRlVO.workAddr,
            		rl_rlRem:data.cstNpBscInfoVO.cstNpSocialRlVO.rlRem,
            		rl_birthday:data.cstNpBscInfoVO.cstNpSocialRlVO.birthday
            	});
            	//性别单独赋值
            	$("input[name='rl_genderCd'][value="+data.cstNpBscInfoVO.cstNpSocialRlVO.genderCd+"]").prev(".l-radio").click();
        	}
        	
        	var formSet1=liger.get("formSet1");
        	var marriageState_val = data.cstNpBscInfoVO.marStsCd
        	if (marriageState_val==CustomerConstant.CST_MAR_STS_CD_2 
        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_first
        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_agian
        			|| marriageState_val==CustomerConstant.CST_MAR_STS_CD_back
        		) {
        		 $("#PO_formSet").removeClass('Hide');
        		 formSet1.setFieldValidate("rl_rlNm", {required: true, nmcharacter:true});
                 formSet1.setFieldValidate("rl_certNo", {required: true});
                 formSet1.setFieldValidate("rl_mp", {required: true, mobile: true});
                 formSet1.setFieldValidate("rl_idAddr", {required: true});
        	}else{
        		 formSet1.setFieldValidate("rl_rlNm", {required: false, nmcharacter:false});
                 formSet1.setFieldValidate("rl_certNo", {required: false});
                 formSet1.setFieldValidate("rl_mp", {required: false, mobile: false});
                 formSet1.setFieldValidate("rl_idAddr", {required: false});
        	}
    	}else{
    		getIdCartBirthday();
    	}
    	
    	$("#cstRlTyp").ligerGetComboBoxManager().setValue(data.cstRlAttr);
    	if(data.cstRlAttrVOList){
    		form.setData({
    			prjCtrlCd:data.prjCtrlCd
        	});
    	}
    	
    	//辅助信息
    	if(data.cstExtInfoVO){
    		tempGuarTypCd = data.cstExtInfoVO.schr6;
    		tempGuarAmt = data.cstExtInfoVO.num9;//1.0E11
    		tempGuarAmt = NumberUtils.isScientificNotationToString(tempGuarAmt);
    		tempSchr7 = data.cstExtInfoVO.schr7;
    		form.setData({
    			ext_schr1:data.cstExtInfoVO.schr1,
    			ext_schr2:data.cstExtInfoVO.schr2,
    			ext_schr3:data.cstExtInfoVO.schr3,
    			ext_schr4:data.cstExtInfoVO.schr4,
    			ext_schr5:data.cstExtInfoVO.schr5,
    			ext_schr6:data.cstExtInfoVO.schr6,
    			schr7:data.cstExtInfoVO.schr7,
    			ext_mchr1:data.cstExtInfoVO.mchr1,
    			ext_mchr2:data.cstExtInfoVO.mchr2,
    			ext_mchr4:data.cstExtInfoVO.mchr4,
    			ext_mchr5:data.cstExtInfoVO.mchr5,
    			ext_mchr6:data.cstExtInfoVO.mchr6,
    			ext_mchr7:data.cstExtInfoVO.mchr7,
    			ext_mchr8:data.cstExtInfoVO.mchr8,
    			ext_bchr1:data.cstExtInfoVO.bchr1,
    			ext_bchr2:data.cstExtInfoVO.bchr2,
    			ext_num1:data.cstExtInfoVO.num1,
    			ext_num2:data.cstExtInfoVO.num2,
    			ext_num3:data.cstExtInfoVO.num3,
    			ext_num4:data.cstExtInfoVO.num4,
    			ext_num5:data.cstExtInfoVO.num5,
    			ext_num6:data.cstExtInfoVO.num6,
    			ext_num7:data.cstExtInfoVO.num7,
    			ext_num8:data.cstExtInfoVO.num8,
    			ext_num9:data.cstExtInfoVO.num9
        	});
    	}
    	
    }

    //保存基本信息
    function saveBscInfo(json){
    	var form = liger.get("formSet1");
        var data = form.getData();
        var flag = checkDateFormat();
        if(flag != 1){
        	return ;
        }
		//检查客户是否存在
        data["npCertTypCd"] = data.certTypCd;
        var isExist = checkNpIsExist(data);
        if(isExist == 1){
        	$.ligerDialog.SQalert({content: "修改后的客户信息与系统中的其他客户信息重复！",SQ_type: "error"});
        	return ;
        }
        //验证手机三要素-REQ-3424
        // var cfcaFlag = checkThreeElements(data);
       	// if(cfcaFlag == 0){
        //    	return ;
		// }
        var genderCd = $('input[name="genderCd"]:checked ').val();
        data["genderCd"] = genderCd;
        data["birthday"] = $("#birthday").val();
        //配偶信息
        var rl_genderCd = $('input[name="rl_genderCd"]:checked ').val();
        data["rl_genderCd"] = rl_genderCd;
//         //流程参数
//         if (StringUtils.isNotEmpty(json)) {
//             data["procDefKey"] = json.procDefKey;
//             data["procDefId"] = json.procDefId;
//             data["procNo"] = json.procNo;
//         }
        data["modFlag"] = "yes";
        data["isFlow"] = isFlow ;
        data["isModify"]= isModify;
        data["modId"]= modId;
        data["currentBuOrgCd"] = currentBuOrgCd;
        var url = '<%=path%>/customer/cstbscinfo/modifyNp.do';
        var id = $("#cId").val();
        if(id != ""){
        	data["id"]= id;
        }else{
       		$.ligerDialog.SQalert({content: "客户ID未获取到，无法继续操作！",SQ_type: "warning"});
       		return;
        }
        
        var docArray = JSON.stringify(getUploadResultParams());
        
        //赋值附件
        data["docArray"] = docArray;
		//请求
        AjaxUtils.ajaxPost(url, data, function(msg){
        	if(msg.success == 1){
        		top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
				 if(msg.data){
					 $("#cId").val(msg.data);
					 reloadCstRlGrid(msg.data);
				 }
				 //成功后要禁用姓名和身份证号码
				 disableVIDInfo();
				 pageInApp.flag = false;
				 //刷新附件页面GRID方法和清空上传按钮
				 refreshUlFileRecListByPkId(msg.data,"CST_BSC_INFO");
				 clearUploadResultParams();
				 if(!modId){
					 Remove_navTab();//关闭申请窗口
				 }
			 }else{
				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
			 }
        }, true);
    }
    
    function checkDateFormat(){
    	var flag = 0;
    	var params = {};
    	params["certValidSDt"] = $("#certValidSDt").val();
    	params["certValidEDt"] = $("#certValidEDt").val();
    	$.ajax({
    		type:'get',
    		dataType:'json',
    		async:false,
    		url:'<%=path%>/customer/cstbscinfo/checkCertValid.do',
    		data:params,
    		success:function(data){
    			//$.ligerDialog.SQalert({content: data.info,SQ_type: "success"});	
    			if(data.success == 1){
    				flag = 1;
    			}else{
    				UIUtils.alertError(data.info);
    			}
    		},
    		error:function(data){
    			UIUtils.alertError(data.info);
    		}
    	});
    	return flag;
    }
    
    //删除客户关系
    function deleteRow(rlId, gridId) {
    	var cId = $("#cId").val();
    	if(!cId){
    		UIUtils.alertWarning(LogUtils.LOG_CUST_ID_NOT_EMPTY);
    		return;
    	}
    	
    	$.ligerDialog.SQconfirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;

			var _url = "<%=path%>/customer/cstnpsocialrl/removeById.do";
			AjaxUtils.ajaxPost(_url, {id:rlId}, function(msg){
				 if(msg.success == 1){
	     				$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
	     				reloadCstRlGrid(cId);
	     	 	 }else{
	     				$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	     		 }
			},true);
		});
    }
    
    //初始化表单中默认显示数据-只有新增会有默认值赋值
    function initFormData(){
    	var cId = $("#cId").val();
    	if(cId){
    		return;
    	}
    	var form = new liger.get("formSet1");
    	form.setData({
    		prjCtrlCd:CustomerConstant.CST_PRJ_CTRL_CD_NO_CTRL,
    		payTypCd:CustomerConstant.CST_PAY_TYP_CD_ONLY_APP
    	});
    }
    
    //禁用重要的信息-本人
    function disableVIDInfo(){
    	liger.get("cstNm").setDisabled(true);
    	liger.get("certTypCd").setDisabled(true);
    	liger.get("certNo").setDisabled(true);
    }
    
	//禁用重要的信息-配偶
    function disableRlVIDInfo(){
    	liger.get("rl_rlNm").setDisabled(true);
    	liger.get("rl_certTypCd").setDisabled(true);
    	liger.get("rl_certNo").setDisabled(true);
    }
    
    //验证身份通过-本人
    function getVerfiedIDHtmlPass(){
    	var html="<span class='liger_tip' id='addNpVerifyID' pass='y' title='"+LogUtils.LOG_CMM_VALID_PASS+"'><i class='sqIco sqIco_1'></i></span>";
    	return html;
    }
    
	//验证身份证未通过-本人
    function getVerfiedIDHtmlNopass(){
    	var html="<a href='javascript:;' id='addNpVerifyID' pass='n' class='liger_tip' title='"+LogUtils.LOG_CMM_VALID_FAIL+"'><i class='sqIco sqIco_2'></i></a>";
    	return html;
    }
	
    //验证身份通过-配偶
    function getPOVerfiedIDHtmlPass(){
    	var html="<span class='liger_tip' id='poVerifyID' pass='y' title='"+LogUtils.LOG_CMM_VALID_PASS+"'><i class='sqIco sqIco_1'></i></span>";
    	return html;
    }
    
	//验证身份证未通过-配偶
    function getPOVerfiedIDHtmlNopass(){
    	var html="<a href='javascript:;' id='poVerifyID' pass='n' class='liger_tip' title='"+LogUtils.LOG_CMM_VALID_FAIL+"'><i class='sqIco sqIco_2'></i></a>";
    	return html;
    }
    
    //加载客户关系数据
    function reloadCstRlGrid(_cstId){
    	 npSocialRlGrid.setParm("cstId",_cstId);
		 npSocialRlGrid.reload();
    }
    
	//身份证第三方验证事件-自然人
    function npVerifyIDEvent(){
    	//$(".addNpVerifyID").on('click', function(event) {
			//显示图片验证-本人
			if($("#certTypCd").val()==0){
				$("#sNpVerifyID").show();
			}else{
				$("#sNpVerifyID").hide();
			}
    		//判断是否已验证
   			if($("#addNpVerifyID").attr("pass") == 'y'){
       			return;
       		}
    		
    		//上面是判断是否完成验证,如果完成了就停止,下面继续
    		var form = new liger.get("formSet1");
    		if (!form.valid()) {
				$.ligerDialog.SQalert({content: "请填写正确信息！",SQ_type: "warning"});
				return false; //验证不通过，不执行以下代码
			}
            var wait_dialog = UIUtils.alertWaiting(LogUtils.LOG_CMM_DATA_LOADING);
            var data = form.getData();
            //alert(JSON.stringify(data));
            var cstNm = data.cstNm;//客户名称
            var certNo = data.certNo;//证件号码
            var validNmTip = LogUtils.LOG_CUST_NAME_NOT_EMPTY;
            var validNoTip = LogUtils.LOG_CUST_ID_CARD_NOT_EMPTY;
            
            if(!cstNm){
            	wait_dialog.close();
            	UIUtils.alertWarning(validNmTip);
                return; //验证不通过，不执行以下代码
            }
            if(!certNo){
            	wait_dialog.close();
            	UIUtils.alertWarning(validNoTip);
                return; //验证不通过，不执行以下代码
            }
            
            _mySelfIDImgUrl = "";//每次验证都要赋空值在赋新值
            
            $.ajax({
           		type: 'post',
           		dataType:'json',
           		data:{cstNm:cstNm,certNo:certNo},
           		url: '<%=path%>/customer/cstbscinfo/validateIdCard.do',
           		success:function(msg){
           			 wait_dialog.close();
           			 if(msg.success == 1){
           				if(msg.data){
           					if(msg.data.absolutePath){
           						//把这个地址记录上,后面要随保存数据一起存储
           						_mySelfIDImgUrl = msg.data.absolutePath;
           					}
           				}
           				//说明已经三方验证通过
           				UIUtils.alertSuccess(msg.info);
                        disableVIDInfo(); //验证通过后直接禁用输入框
                        $("#sNpVerifyID").html(getVerfiedIDHtmlPass());
                        $(".liger_tip").ligerTip(); // HTML元素更新后，重新ligerTip实例化
           			 }else{//验证未通过
                         UIUtils.alertWarning(msg.info);
           			 }
           		}
            });
            
		//});
    }
    
	//证件号变更-设置验证初始值为不通过-重新验证
	function setNpPassNo(){//本人
		//$("#addNpVerifyID").attr("pass","n");
		$("#sNpVerifyID").html(getVerfiedIDHtmlNopass());
		//添加身份证号前台校验
		var formSet1=liger.get("formSet1");
		formSet1.setFieldValidate("certNo", {required:true, idcardno: true});
	}
	function setPoPassNo(){//配偶
		//$("#poVerifyID").attr("pass","n");
		$("#peiouVerifyID").html(getPOVerfiedIDHtmlNopass());
		//添加身份证号前台校验
		var formSet1=liger.get("formSet1");
		formSet1.setFieldValidate("rl_certNo", {required:true, idcardno: true});
	}
	
    //验证配偶身份信息
    function poVerifyId(){
		//显示验证图片按钮-配偶
		if($("#rl_certTypCd").val()==0){
			$("#peiouVerifyID").show();
		}else{
			$("#peiouVerifyID").hide();
		}
		if($("#poVerifyID").attr("pass") == 'y'){
			return;
		}
        var ligerForm=liger.get("formSet1");
        if (!ligerForm.valid()) {
			$.ligerDialog.SQalert({content: "请填写正确信息！",SQ_type: "warning"});
			return false; //验证不通过，不执行以下代码
		}
        var custNm = $("#rl_rlNm").val();
        var certNo = $("#rl_certNo").val();
        if(!custNm){
        	UIUtils.alertWarning(LogUtils.LOG_CUST_NAME_NOT_EMPTY);
            return; //验证不通过，不执行以下代码
        }
        var rlNmFlag = ligerForm.validator.element("#rl_rlNm");
        if(!rlNmFlag){
        	$.ligerDialog.SQalert({content: "请输入正确的姓名!", SQ_type: "warning"});
            return; //验证不通过，不执行以下代码
        }
        if(!certNo){
        	UIUtils.alertWarning(LogUtils.LOG_CUST_ID_CARD_NOT_EMPTY);
            return; //验证不通过，不执行以下代码
        }
        var _url = '<%=path%>/customer/cstbscinfo/validateIdCard.do';
        AjaxUtils.ajaxPost(_url, {cstNm:custNm,certNo:certNo}, function(msg){
        	if(msg.success == 1){
   				if(msg.data){
   					if(msg.data.absolutePath){
   						//把这个地址记录上,当点击的时候要随保存数据一起存储
   						$("#myPeiOuImgUrl").val(msg.data.absolutePath);
   						$("#myPeiOuImgUrlAll").attr('src',msg.data.relativePath);
   					}
   				}
   				//说明已经三方验证通过
   				UIUtils.alertSuccess(msg.info);
   				disableRlVIDInfo(); //验证通过后直接禁用输入框
                $("#peiouVerifyID").html(getPOVerfiedIDHtmlPass());
                $(".liger_tip").ligerTip(); // HTML元素更新后，重新ligerTip实例化
   			 }else{//验证未通过
                 UIUtils.alertWarning(msg.info);
                 $("#myPeiOuImgUrl").attr('src',"");
   			 }
        },true);
    }
    
    //设置表单域是否可修改状态：通过true(禁用) false(启用)
    function changeModStatus(tf) {
    	//判断客户状态（13：已立项  14：有担保项目） 
    	if(_audStsCd == "13" || _audStsCd == "14"){//只能修改手机号
    		//本人信息
    		if (liger.get("cstNm")) {//客户姓名-禁用
	            liger.get("cstNm").setDisabled(true);
	        }
	        if (liger.get("certNo")) {//证件号-禁用
	            liger.get("certNo").setDisabled(true);
	        }
	        //配偶信息
	        if (liger.get("rl_rlNm")) {//配偶姓名-禁用
	            liger.get("rl_rlNm").setDisabled(true);
	        }
	        if (liger.get("rl_certNo")) {//配偶身份证号-禁用
	            liger.get("rl_certNo").setDisabled(true);
	        }
	        if (liger.get("rl_mp")) {//配偶手机号码-禁用
	            liger.get("rl_mp").setDisabled(true);
	        }
    	}else{
    		//本人信息
	        if (liger.get("cstNm")) {//客户姓名
	            var obj = liger.get("cstNm");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
	        if (liger.get("certNo")) {//证件号
	            var obj = liger.get("certNo");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
	        //配偶信息
	        if (liger.get("rl_rlNm")) {//配偶姓名
	            var obj = liger.get("rl_rlNm");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
	        if (liger.get("rl_certNo")) {//配偶身份证号
	            var obj = liger.get("rl_certNo");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
	        if (liger.get("rl_mp")) {//配偶手机号码
	            var obj = liger.get("rl_mp");
	            tf == true ? obj.setDisabled() : obj.setEnabled();
	        }
    	}
    	//按需设置
        // if (liger.get("mp1")) {//手机号1
        //     var obj = liger.get("mp1");
        //     tf == true ? obj.setDisabled() : obj.setEnabled();
        // }
    }
    
	//检查是否存在客户信息-自然人
	function checkNpIsExist(_data){
		var isExist = 0;
		var cId = $("#cId").val();
		var _url = '<%=path%>/customer/cstbscinfo/getExistNp.do';
		$.ajax({
    		type:'get',
    		dataType:'json',
    		async:false,
    		url:_url,
    		data:_data,
    		success:function(msg){
    			if(msg.success == 1){//存在
					//返回的客户ID
					var _id = msg.data.cId;
					if(cId != _id){
						isExist = 1;
					}
				}else if(msg.success == 3){//不存在
					isExist = 0;
				}else{
					UIUtils.alertError(msg.info);
				}
    		},
    		error:function(msg){
    			UIUtils.alertError(msg.info);
    		}
    	});
		return isExist;
	}
	
	//判断页面是否有变更
	var isChange = 0;
	var arrays = ["cstNm","certNo","mp1","rl_rlNm","rl_certNo","rl_mp"];
	for(var i=0;i<arrays.length;i++){
		$("#"+arrays[i]).on("change",changeEvent);
	}
	
	//处理变更事件
	function changeEvent(){
		isChange = 1;
	}
    
    </script>
</body>
</html>